package com.wpf.system.service.impl;

import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wpf.system.entity.EquipmentBuy;
import com.wpf.system.entity.dto.BookRentBuySearchDTO;
import com.wpf.system.entity.vo.EquipmentBagVO;
import com.wpf.system.entity.vo.EquipmentBuyVO;
import com.wpf.system.entity.vo.EquipmentChartVO;
import com.wpf.system.service.EquipmentBuyService;
import com.wpf.system.mapper.EquipmentBuyMapper;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
* @author ferna
* @description 针对表【equipment_buy(器材购买记录表)】的数据库操作Service实现
* @createDate 2023-02-14 21:21:48
*/
@Service
public class EquipmentBuyServiceImpl extends ServiceImpl<EquipmentBuyMapper, EquipmentBuy> implements EquipmentBuyService{

    @Override
    public List<EquipmentBagVO> getBackEquipmentInfo(List<Long> ids) {
        return this.baseMapper.getBackEquipmentInfo(ids);
    }

    @Override
    public List<EquipmentBuyVO> getAllEquipmentBuy(BookRentBuySearchDTO bookRentBuySearchDTO) {
        return this.baseMapper.getAllEquipmentBuy(
                bookRentBuySearchDTO.getNo(),
                bookRentBuySearchDTO.getUid(),
                bookRentBuySearchDTO.getName(),
                bookRentBuySearchDTO.getNid(),
                bookRentBuySearchDTO.getUsername(),
                bookRentBuySearchDTO.getPhone(),
                bookRentBuySearchDTO.getStartTime(),
                bookRentBuySearchDTO.getEndTime(),
                bookRentBuySearchDTO.getPage(),
                bookRentBuySearchDTO.getPageSize()
        );
    }

    @Override
    public int deleteEquipmentBuyByIds(List<Long> ids) {
        return this.baseMapper.deleteEquipmentBuyByIds(ids);
    }

    @Override
    public List<EquipmentChartVO> getEquipmentBuyChartData(String date) {
        Date d = DateUtil.parse(date);
        return this.baseMapper.getEquipmentBuyChartData(
                DateUtil.beginOfDay(d).toString("yyyy-MM-dd HH:mm:ss"),
                DateUtil.endOfDay(d).toString("yyyy-MM-dd HH:mm:ss")
        );
    }
}




